home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 6 / QRZ Ham Radio Callsign Database - Volume 6.iso / pc / files / dsp / 56100tar.z / 56100tar / 56100 / g722 / g722code / g722_156.asm next >
Encoding:
Assembly Source File  |  1992-04-15  |  52.8 KB  |  1,745 lines

  1.     opt mu,cc
  2.     page 60,60
  3.  
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5. ;;                                        ;
  6. ;;     File        : g722_156.asm                                 ;
  7. ;;                                        ;
  8. ;;    Date        : February 21 1992                    ;
  9. ;;                                        ;
  10. ;;      Program for testing the encoder and decoder of G722. Including the QMF    ;
  11. ;;    transmit and receive filters                        ;
  12. ;;                                        ;
  13. ;;    Author(s)    : Jean-Pierre Petit                    ;
  14. ;;              Speech Signal Processing Applications            ;
  15. ;;              Centre National d'Etudes des Telecommunications    ;
  16. ;;              LAA-TSS                        ;
  17. ;;              Route de Tregastel - BP40                ;
  18. ;;              Lannion                        ;
  19. ;;              France                        ;
  20. ;;                                        ;
  21. ;;    Tel.        : N/A                            ;
  22. ;;                                        ;
  23. ;;              Phil Atherton                        ;
  24. ;;              DSP Applications Group                ;
  25. ;;              Motorola Semiconductors Ltd                ;
  26. ;;              Colvilles Road                    ;
  27. ;;              Kelvin Industrial Estate                ;
  28. ;;              East Kilbride                        ;
  29. ;;              Scotland                        ;
  30. ;;                                        ;
  31. ;;    Tel.        : (+44/0) 3552 40377                    ;
  32. ;;                                        ;
  33. ;;    Target System    : DSP56156                        ;
  34. ;;              16 bit Signal Processor                ;
  35. ;;                                        ;
  36. ;;    Registers used    : all                            ;
  37. ;;                                        ;
  38. ;;    Inputs required    : Tx QMF & Encoder : Min. 14 bit 2's complement A/D    ;
  39. ;;                         data @ 16 kHz sampling frequency    ;
  40. ;;                                        ;
  41. ;;              Mode of G.722       : from external file MODCOD.TST    ;
  42. ;;              Decoder                        ;
  43. ;;                                        ;
  44. ;;    Outputs given    : Decoder & Rx QMF : 16 bit 2's complement D/A data    ;
  45. ;;                         @ 16 kHz                ;
  46. ;;                                        ;
  47. ;;    Revision    : 1.02                            ;
  48. ;;                                        ;                                        ;
  49. ;;    Last Revision    : 14 February 1992                    ;
  50. ;;    Date                                    ;
  51. ;;                                        ;
  52. ;;      Notes: This version inludes the initialization of the data Ram on a    ;
  53. ;;    hardware reset; this means that the program can be burned in a PROM.    ;
  54. ;;                                        ;
  55. ;;     The mode of decoder is read in from a file by the Application system    ;
  56. ;;    (file MODCOD.TST).                            ;
  57. ;;                                        ;
  58. ;;    The ISDN network is simulated by looping ssi0 tx back to ssi0 rx    ;
  59. ;;                                        ;                                        ;
  60. ;;    This version uses interrupts for the on chip codec board and polls    ;
  61. ;;    the ssi0 rx rdf flag for ISDN data                    ;
  62. ;;                                        ;
  63. ;;    This version requires a 32 MHz Extal frequency to generate the 16 kHz    ;
  64. ;;    codec sampling frequency, 8 kHz ssi0 ISDN sampling frequency and the    ;
  65. ;;    40 MHz core clock frequency.                        ;
  66. ;;                                                                        ;
  67. ;;               Copyright MOTOROLA and CNET France Telecom                  ;
  68. ;;                                                                           ;
  69. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  70. ;;
  71. ;;      Interrupt equates
  72. ;;    =================
  73. ;;
  74. a_ipl        equ $ffdf            ; address of ipl reg
  75. set_ipl        equ $00c0            ; enable codec interrupts
  76. set_mr        equ $fc                ; no masked interrupt
  77. ;;
  78. ;;    Port C equates
  79. ;;    ==============
  80. ;;
  81. a_pcc        equ $ffc1            ; port C control
  82. set_pcc        equ $001f            ; set port C as ssi0 
  83. ;;                        ; enable ssi0
  84. ;;
  85. ;;    SSI0 equates
  86. ;;    ============
  87. ;;
  88. a_txrx_0    equ $fff1            ; address tx and rx
  89. a_sr_0        equ $fff0            ; address status reg. ssi0
  90. a_crb_0        equ $ffd1            ; address ssi0 crb
  91. a_cra_0        equ $ffd0            ; address ssi0 cra
  92. ;;
  93. set_cra_0    equ $007d                       ; no ÷ 2 prescaler
  94.                         ; 8 bits
  95.                         ; normal operation
  96.                         ; ÷ 125 gives 8 bits @ 8 kHz
  97.                         ; clock rate for 32 MHz
  98.                         ; crystal frequency
  99. ;;
  100. set_crb_0a    equ $0430            ; no rx or tx enable yet
  101. set_crb_0    equ $3430                       ; rx & tx enable
  102.                         ; normal mode
  103.                         ; synchronous mode
  104.                         ; active high frame sync.
  105.                         ; word length frame sync.
  106.                         ; msb first
  107.                         ; data out rising clock edge
  108.                         ; data in falling clock edge
  109.                         ; internal clock
  110.                         ; internal frame sync.
  111.                         ; SC00 = tx frame sync output
  112. ;;
  113. rdf_flag    equ $0008            ; rdf flag bit position in
  114.                         ; ssi0 
  115. ;;
  116. ;;    PLL Equates
  117. ;;    ===========
  118. ;;
  119. a_plcr        equ $ffdc            ; PLL control register
  120. ;;
  121. set_plcr    equ $404f            ; Codec input clock = Extal/16
  122.                         ; 56156 core clock  = Extal*(20÷16)
  123.                         ; Clockout pin      = FExt/2 to Clk0
  124.                         ; Not GSM mode
  125.                         ; Not Low power mode
  126.                         ; Enabled
  127. ;;
  128. enable_pll    equ $4000            ; PLL Enable bit
  129. ;;
  130. ;;
  131. ;;    Codec Equates
  132. ;;    =============
  133. ;;
  134. a_codec_txrx    equ $ffe9            ; Codec tx & rx register
  135. ;;
  136. a_codec_cr    equ $ffc8            ; Codec control register
  137. a_codec_sr    equ $ffe8            ; Codec status register 
  138. ;;
  139. set_codec    equ $c404            ; Enable codec interrupts
  140.                         ; Enable codec
  141.                         ; Microphone input
  142.                         ; Microphone gain = -6 dB
  143.                         ; Non-mute
  144.                         ; Decimation/Interpolation
  145.                         ; codec ratio = 125
  146.                         ; Disable test bits
  147.                         ; 0 dB gain
  148. ;;
  149. ;;****************************************************************
  150. ;;
  151. ;;    Simulation of hard reset
  152. ;;    ========================
  153. ;;
  154.     org    p:$00
  155.     jmp     prog
  156. ;;
  157. ;;    Interrupt Service routines
  158. ;;    ==========================
  159. ;;
  160.     org    p:$0010
  161.     jsr     roe_rx_0            ; receive rx_0 execption
  162. ;;
  163.     org    p:$0014
  164.     jsr     tue_tx_0            ; transmit tx_0 exception
  165. ;;
  166.     org    p:$002e            
  167.     jsr    codec_data            ; on-chip codec data ready
  168. ;;
  169. ;;
  170. ;;****************************************************************
  171. ;;
  172. ;;    Area of X RAM
  173. ;;    =============
  174. ;;
  175.     org x:$00
  176. ;;
  177. ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  178. ;;
  179. ;;    data for test
  180. ;;    =============
  181. ;;
  182. temp_x0        ds    1    ; temporary storage for x0
  183. ;;
  184. mode        ds    1    ; mode of decoder from MODCOD.TST file
  185. ;;
  186. first_codec_tx    ds    1    ; first G722 interpolated data to codec
  187. second_codec_tx    ds    1    ; second G722 interpolated data to codec
  188. ;;
  189. first_codec_rx    ds    1    ; first G722 data from codec
  190. second_codec_rx    ds    1    ; second G722 data from codec
  191. ;;
  192. ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  193. ;;
  194. ;;    data for predictor in lower sub band coder
  195. ;;    ==========================================
  196. ;;
  197. dat_lsbcod     ds     23    ; data ram for the lower sub band predictor
  198. xl_cod         ds     1    ; input of lsbcod
  199. il_cod         ds     1    ; output of lsbcod
  200. ;;
  201. ;;
  202. ;;    data for predictor in higher sub band coder
  203. ;;    ===========================================
  204. ;;
  205. dat_hsbcod     ds     23    ; data ram for the higher sub band predictor
  206. xh_cod         ds     1    ; input of hsbcod
  207. ih_cod         ds     1    ; output of hsbcod
  208. ;;
  209. ;;    data for predictor in lower sub band decoder
  210. ;;    ============================================
  211. ;;
  212. dat_lsbdec     ds     23    ; data ram for the lower sub band predictor
  213. ilr_dec         ds     1    ; input of lsbdec
  214. yl_dec         ds     1    ; output of lsbdec
  215. ;;
  216. ;;;    data for predictor in higher sub band decoder
  217. ;;    =============================================
  218. ;;
  219. dat_hsbdec     ds     23    ; data ram for the higher sub band predictor
  220. ihr_dec         ds     1    ; input of hsbdec
  221. yh_dec         ds     1    ; output of hsbdec
  222. ;;
  223. ;;    output of encoder
  224. ;;    =================
  225. ;;
  226. is        ds     1    ; output code of encoder
  227. ;;
  228. ;;    input of decoder
  229. ;;    ================
  230. ;;
  231. ir        ds     1    ; receive code for input of decoder
  232. ;;
  233. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  234. ;;
  235. ;;    ============================================================
  236. ;;    This data ram area is initialized at reset by the init_const
  237. ;;    procedure
  238. ;;    ============================================================
  239. ;;
  240. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  241. ;;
  242. ;;    Table for selection of decoder (mode)
  243. ;;    =====================================
  244. ;;
  245. sel_mode    ds     1    ; for mode 1 = 64 kbit/s
  246.         ds     1    ; for mode 2 = 56 kbit/s
  247.         ds     1    ; for mode 3 = 48 kbit/s
  248. ;;
  249. ;;    constant area for lower sub band predictor
  250. ;;    ==========================================
  251. ;;
  252. const_pr_l     ds     1    ; inverse 4 bits quantizer
  253.         ds     1    ; log adaptation (4 bits)
  254.         ds     1    ; multiplicand factor
  255.         ds     1    ; upper limit of p_nbl (low sub band)
  256.         ds     1    ; to compute shift right
  257.         ds     1    ; table of 32 values
  258. ;;
  259. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  260. ;;
  261. ;;    constant area for higher sub band predictor
  262. ;;    ===========================================
  263. ;;
  264. const_pr_h     ds     1    ; inverse 2 bits quantizer
  265.         ds     1    ; log adaptation (2 bits)
  266.         ds     1    ; multiplicand factor
  267.         ds     1    ; upper limit of p_nbl (high sub band)
  268.         ds     1    ; to compute shift right
  269.         ds     1    ; table of 32 values
  270. ;;
  271. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  272. ;
  273. ;    quantizer thresholds (Q6) for lower sub_band encoder
  274. ;    ====================================================
  275. ;
  276. level__1    ds     1    ; Q6(-1)
  277. level_0        ds     1    ; Q6( 0)
  278. level_1        ds     1    ; Q6( 1)
  279. level_2        ds     1    ; Q6( 2)
  280. level_3        ds     1    ; Q6( 3)
  281. level_4        ds     1    ; Q6( 4)
  282. level_5        ds     1    ; Q6( 5)
  283. level_6        ds     1    ; Q6( 6)
  284. level_7        ds     1    ; Q6( 7)
  285. level_8        ds     1    ; Q6( 8)
  286. level_9        ds     1    ; Q6( 9)
  287. level_10    ds     1    ; Q6(10)
  288. level_11    ds     1    ; Q6(11)
  289. level_12    ds     1    ; Q6(19)
  290. level_13    ds     1    ; Q6(13)
  291. level_14    ds     1    ; Q6(14)
  292. level_15    ds     1    ; Q6(15)
  293. level_16    ds     1    ; Q6(16)
  294. level_17    ds     1    ; Q6(17)
  295. level_18    ds     1    ; Q6(18)
  296. level_19    ds     1    ; Q6(19)
  297. level_20    ds     1    ; Q6(20)
  298. level_21    ds     1    ; Q6(21)
  299. level_22    ds     1    ; Q6(22)
  300. level_23    ds     1    ; Q6(23)
  301. level_24    ds     1    ; Q6(24)
  302. level_25    ds     1    ; Q6(25)
  303. level_26    ds     1    ; Q6(26)
  304. level_27    ds     1    ; Q6(27)
  305. level_28    ds     1    ; Q6(28)
  306. level_29    ds     1    ; Q6(29)
  307. ;
  308. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  309. ;;
  310. ;;    Coefficients for QMF TX and RX filters
  311. ;;    ======================================
  312. ;;    Note: they must be seen as H[23],H[22] and so on
  313. ;;    ------------------------------------------------
  314. ;;
  315. q_coef        ds     24    ; for 24 coeffiecents
  316. ;;
  317. ;;=====================================================================
  318. ;;        QMF sections
  319. ;;        ============
  320. ;;=====================================================================
  321. ;;
  322. ;;    address for modulo arithmetic of delay TX line
  323. ;;    ==============================================
  324.     org    x:$100
  325. ;;
  326. dat_q_tx    ds    24    ; delay line for QMF tx filter
  327. ptr_q_tx    ds    1    ; modulo pointer to dat_q_tx
  328. ;;
  329. ;;
  330. ;;    address for modulo arithmetic of delay RX line
  331. ;;    ==============================================
  332.     org    x:$200
  333. ;;
  334. dat_q_rx    ds    24    ; delay line for QMF rx filter
  335. ptr_q_rx    ds    1    ; modulo pointer to dat_q_rx
  336. ;;
  337. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  338. ;;
  339. ;;    Beginning of test program
  340. ;;    ========================
  341. ;;
  342.         org     p:$40
  343. ;;
  344. prog        reset            ; reset on chip peripherals
  345.         nop            ; for the pipeline
  346.         nop
  347. ;;
  348.         ori     #$30,omr    ; saturation 32 bits,rounding 2s
  349.         nop            ; for the pipeline
  350.         nop
  351. ;;
  352. ;;    Reset section
  353. ;;    =============
  354. ;;
  355.         jsr     init_const    ; init const in ram
  356.         jsr     reset_cod    ; encoder reset
  357.         jsr     reset_dec    ; decoder reset
  358.         jsr     init_q_tx    ; reset qmf tx
  359.         jsr     init_q_rx    ; reset qmf rx
  360. ;;
  361. ;;    ==============================================================
  362. ;;    read mode of decoder (not significant for encoder)
  363. ;;    mode 1, 2 or 3 is valid (64, 56 and 48 kbits/sec)
  364. ;;    ==============================================================
  365. ;;
  366. ;;    Apps input: select mode of decoder
  367. ;;    ==================================
  368. ;;
  369.         move    #$0101,x0    ; file #1 with 1 values input
  370.         move    #1,r1        ; data resides in x memory
  371.         move    #mode,r0     ; in variable x:mode
  372.  
  373.         org p:            ; for reference
  374. DEBI_CDMO    debug
  375.         nop            ; for the pipeline
  376.         nop
  377. ;;
  378. ;;    Initialise PLL
  379. ;;    ==============
  380. ;;
  381.         move    #set_plcr,x0    ; set pll operating mode in x0
  382.         move    x0,x:a_plcr    ; write to PLL control reg
  383. ;;
  384. ;;    Initialise Codec
  385. ;;    ================
  386. ;;
  387.         move    #set_codec,x0    ; Codec operating mode in x0
  388.         move    x0,x:a_codec_cr    ; Write to codec control register         
  389. ;;
  390. ;;    Initialise SSI0
  391. ;;    ===============
  392. ;;
  393.         move     #set_cra_0,b    ; set mode cra in x
  394.         move     b1,x:a_cra_0    ; set mode in cra0
  395.  
  396.         move     #set_crb_0a,b    ; set mode crb in x0
  397.         move     b1,x:a_crb_0    ; set mode in crb_0
  398.  
  399.         move     #set_pcc,b    ; for ssi in port c
  400.         move     b1,x:a_pcc    ; set port c ssi0/1
  401.  
  402.         move     b0,x:a_txrx_0    ; write 0 to ssi0 tx
  403.                     ; for init
  404.         move    #set_crb_0,b    ; enable tx & rx in ssi0
  405.         move    b1,x:a_crb_0
  406. ;;
  407. ;;    Set interrupt priority and mode register
  408. ;;    ========================================
  409. ;;
  410.         move     #set_ipl,x0    ; set x0 with ipl
  411.         move     x0,x:a_ipl    ; write ipl to enable codec interrupts
  412.         andi     #set_mr,mr    ; unmask all interrupts
  413. ;;
  414. ;;
  415. ;;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  416. ;;
  417. ;;    ==========
  418. ;;    Main loop
  419. ;;    ==========
  420.  
  421.         do     forever,sequence    ; forever i/o loop
  422.         
  423.         nop
  424.         nop
  425.         nop
  426.         
  427. sequence
  428. ;;
  429. ;;***********************************************************************
  430. ;;*                                    *
  431. ;;*            End of Main program loop            *
  432. ;;*                                    *
  433. ;;***********************************************************************
  434. ;;
  435. ;;*******************************************************************
  436. ;;
  437. ;;     Interrupt routine
  438. ;;    =================
  439. ;;
  440. codec_data    bftsth    #rdf_flag,x:a_sr_0    ; test for ISDN network 
  441.         bcs    <isdn_rx        ; reception, if yes then
  442.                         ; process G722 decoder
  443. ;;
  444. ;;    Get 2nd 16 kHz codec data for qmf_tx
  445. ;;    ====================================
  446. ;;
  447.         move    x:a_codec_txrx,x0    ; get last qmf_tx input 
  448.         move    x0,x:second_codec_rx    ; before G722 encoding
  449. ;;
  450. ;;    Beginning of G722 encoder
  451. ;;    =========================
  452. ;;
  453. ;;    Call qmftx procedure
  454. ;;    ====================
  455. ;;
  456.         jsr     qmf_tx            ; transmit qmf
  457. ;;
  458. ;;    Call encoder procedure
  459. ;;    ======================
  460. ;;
  461.         jsr     encoder            ; call G722 encoder
  462. ;;
  463. ;;    Send 2nd interpolated G722 data to codec
  464. ;;    ========================================
  465. ;;
  466.         move    x:second_codec_tx,x0    ; transmit the second
  467.         move    x0,x:a_codec_txrx    ; interpolated G722 o/p
  468. ;;
  469.         bra    <end_interrupt        ; 8 kHz section completed
  470. ;;
  471. ;;    Network transmission
  472. ;;    ====================
  473. ;;
  474. isdn_rx        move    x:is,x0            ; Get latest G722 encode data
  475.         move    x0,x:a_txrx_0        ; and send to line
  476. ;;
  477.         move    x:a_txrx_0,x0        ; Get latest ssi0 reception
  478.         move    x0,x:ir            ; and store in "ir"
  479. ;;
  480. ;;    Get 1st 16 kHz Codec data for qmf_tx
  481. ;;    ====================================
  482. ;;
  483.         move    x:a_codec_txrx,x0    ; get the first    16 kHz    
  484.         move    x0,x:first_codec_rx    ; input data for qmf_tx
  485. ;;
  486. ;;    Call decoder procedure
  487. ;;    ======================
  488. ;;
  489.         jsr     decoder            ; call G722 decoder
  490. ;;
  491. ;;    Call qmfrx procdeure
  492. ;;    ====================
  493. ;;
  494.         jsr     qmf_rx            ; receive qmf
  495. ;;
  496. ;;    Send 1st interpolated G722 data to codec
  497. ;;    ========================================
  498. ;;
  499.         move    x:first_codec_tx,x0    ; transmit the first
  500.         move    x0,x:a_codec_txrx    ; interpolated G722 o/p
  501. ;;
  502. end_interrupt    rti
  503. ;;
  504. ;;***********************************************************************
  505. ;;*                                    *
  506. ;;*            End of interrupt routine            *
  507. ;;*                                    *
  508. ;;***********************************************************************
  509. ;;
  510. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  511. ;;                                    ;;
  512. ;; structure of variables for predictor in lower sub band coder           ;;
  513. ;;                                      in higher sub band coder          ;;
  514. ;;                                      in lower sub band decoder         ;;
  515. ;;                                      in higher sub band decoder        ;;
  516. ;; the address of this structure is passed to the subroutine predictor    ;;
  517. ;; in the r2 address register                                             ;;
  518. ;; this structure need 23 words of ram that must be initialized for       ;;
  519. ;; correct oprationof the g722 algorithm (digital test sequence           ;;
  520. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  521. ;;
  522. delt         equ     0        ;
  523. sl            equ     1        ; signal predicted
  524. szl           equ     2        ; output of the zero predictor
  525. p_nbl         equ     3        ; nabla of the predictor
  526. al1           equ     4        ; first pole predictor coefficient
  527. al2           equ     5        ; first pole predictor coefficient
  528. bl1           equ     6        ; zero predictor coefficient
  529. bl2           equ     7        ; zero predictor coefficient
  530. bl3           equ     8        ; zero predictor coefficient
  531. bl4           equ     9        ; zero predictor coefficient
  532. bl5          equ     10        ; zero predictor coefficient
  533. bl6          equ     11        ; zero predictor coefficient
  534. rlt0         equ     12        ; pole signal predictor
  535. rlt1         equ     13        ; pole signal predictor
  536. dlt0         equ     14        ; zero signal predictor
  537. dlt1         equ     15        ; zero signal predictor
  538. dlt2         equ     16        ; zero signal predictor
  539. dlt3         equ     17        ; zero signal predictor
  540. dlt4         equ     18        ; zero signal predictor
  541. dlt5         equ     19        ; zero signal predictor
  542. dlt6         equ     20        ; zero signal predictor
  543. plt0         equ     21        ; pole partial signal predictor
  544. plt1         equ     22        ; pole partial signal predictor
  545. ;;
  546. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  547. ;                                                                   ;
  548. ;   Encoder: G722 encoder                                           ;
  549. ;            Compute the output, is, from inputs, xl_cod and xh_cod ;
  550. ;            First compute il_cod from xl_cod (lsbcod procedure)    ;
  551. ;            Then compute ih_cod from xh_cod (hsbcod procedure)     ;
  552. ;            Finally compute is from il_cod and ih_cod              ;
  553. ;                                                                   ;
  554. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  555. ;
  556. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  557. ;                                                                   ;
  558. ;   Lsbcod : lower sub band coder                                   ;
  559. ;            Compute the output code il_cod from input xl_cod       ;
  560. ;            First compute el then quantize on 6 bits               ;
  561. ;                                    ;
  562. ;   NOTE: entry point of encoder = lsbcod                           ;
  563. ;   =====================================                           ;
  564. ;                                     ;
  565. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  566. ;;
  567. encoder        move     x:xl_cod,a        ; read xl_cod in a
  568.         move     x:(dat_lsbcod+sl),b    ; read prediction
  569.         sub     b,a            ; compute el in a
  570. ;;
  571. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  572. ;                                                                   ;
  573. ;   Quantl : lower sub band 6 bits quantizer                        ;
  574. ;            el in a                                                ;
  575. ;            This procedure use a mixed tree and direct search      ;
  576. ;            to minimize speed and size of code                     ;
  577. ;            A full binary search procedure would save 20 cycles    ;
  578. ;            (10 instructions) but at the expense of 100 words      ;
  579. ;            of program.                                            ;
  580. ;                                                                   ;
  581. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  582. ;;
  583. quantl    move     #cod_6_mi,b        ; select table for el <0
  584.     move     #cod_6_pl,x0        ; select table for el >0
  585.     move     #level_0,r2        ; offset of table level in ram
  586.     tst     a            ; test if sign of el <0
  587.     tpl     x0,b            ; select table >0
  588.     move     b,r0            ; save table in r0
  589.     tfr     a,b     x:(r2+14),x0    ; level 14 in x0
  590.     move     x:dat_lsbcod,y0        ; y0 = detl
  591.     inc24     b            ; to compute |el| of G722
  592.     abs     b      x:(r2+6),x1    ; level 6 in x1
  593.     tst     a            ; test if a >=0
  594.     tmi     b,a            ; a = |el| = wd
  595. ;
  596. ;;    Beginning of the tree search
  597. ;;    ============================
  598. ;;
  599. test_14    mpy     y0,x0,b x:(r2+22),x0    ; level 22 in x0
  600.     move    b,b            ; set lsp of b to 0
  601.     cmp     b,a            ; test wd with level 14
  602.     bpl     <test_22        ; if >0 go test_22
  603. ;
  604. test_6    mpy     y0,x1,b            ; level 6 * detl
  605.     move     b,b            ; set lsp of b to 0
  606.     cmp     b,a            ; test wd with level 6
  607.     bpl     <init_7            ; if >0 go to init_7
  608. ;
  609. init__1    move     #-1,n0            ; set init of r0 index to -1
  610.     move     #level__1,r3        ; set r3 to level__1
  611.     move     x:(r0)+n0,b        ; dummy read to update r0 to r0-1
  612.     bra     <end_q6            ; direct branch to end of procedure
  613. ;
  614. init_7    move     #7,n0            ; set init of r0 index to 7
  615.     move     #level_7,r3        ; set r3 to level_7
  616.     move     x:(r0)+n0,b        ; dummy read to update r0 to r0+7
  617.     bra     <end_q6            ; direct branch to end of procedure
  618. ;;
  619. test_22    mpy     y0,x0,b            ; level 22 * detl
  620.     move     b,b            ; set lsp to b 0
  621.     cmp     b,a            ; test wd with level 22
  622.     bpl     <init_23        ; if >0 go ro init_23
  623. ;
  624. init_15    move     #15,n0            ; set init of r0 index to 15
  625.     move     #level_15,r3        ; set r3 to level_15
  626.     move     x:(r0)+n0,b        ; dummy read to update r0 to r0+15
  627.     bra     <end_q6            ; direct branch to end of procedure
  628. ;
  629. init_23    move     #23,n0            ; set init of r0 index to 23
  630.     move     #level_23,r3        ; set r3 to level_23
  631.     move     x:(r0)+n0,b        ; dummy read to update r0 to r0+23
  632.     bra     <end_q6            ; direct branch to end of procedure
  633. ;
  634. ;;
  635. ;;    Beginning of direct search for 7 values of index
  636. ;;    ================================================
  637. ;;
  638. end_q6    move     r0,r1            ; set r1 to init of r0
  639.     move     x:(r3)+,x0        ; read level -1,7,15,23
  640.     mpy     y0,x0,b  x:(r3)+,x0    ; read level  0,8,16,24
  641.     move     b,y1            ; set lsp of b to 0 (x1)
  642. ;
  643.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 1,9,17,25
  644.     cmp     y1,a      b,y1            ; compare level -1,7,15,23
  645.     tpl     b,b      r0,r1            ; increment r1 if >0
  646. ;
  647.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 2,10,18,26
  648.     cmp     y1,a      b,y1            ; compare level 0,8,16,24
  649.     tpl     b,b      r0,r1            ; increment r1 if >0
  650. ;
  651.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 3,11,19,27
  652.     cmp     y1,a      b,y1            ; compare level 1,9,17,25
  653.     tpl     b,b      r0,r1            ; increment r1 if >0
  654. ;
  655.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 4,12,20,28
  656.     cmp     y1,a      b,y1            ; compare level 2,10,18,26
  657.     tpl     b,b      r0,r1            ; increment r1 if >0
  658. ;
  659.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 5,13,21,29
  660.     cmp     y1,a      b,y1            ; compare level 3,11,19,27
  661.     tpl     b,b      r0,r1            ; increment r1 if >0
  662. ;
  663.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 6,14,22,30
  664.     cmp     y1,a      b,y1            ; compare level 4,12,20,28
  665.     tpl     b,b      r0,r1            ; increment r1 if >0
  666. ;
  667.     cmp     y1,a      x:(r0)+,x1        ; compare level 5,13,21,29
  668.     tpl     b,b      r0,r1            ; increment r1 if >0
  669. ;
  670.     move     #dat_lsbcod,r2        ; set offset for lsbcod
  671.     move     p:(r1),a        ; code il_cod in a
  672.     move     a,x:il_cod        ; save code for lower sub_band
  673. ;;
  674. ;;    We must call subroutine pred_l
  675. ;;    ==============================
  676. ;;
  677.     move     #const_pr_l,r3        ; set constant table for low band
  678.     jsr     pred_l            ; call subroutine pred_l
  679.                     ; with il_cod in a
  680.     move     a,x:(r2+sl)        ; save sl in lsbcod
  681. ;;
  682. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  683. ;                                                                   ;
  684. ;   Hsbcod : higher sub band coder                                  ;
  685. ;            Compute the output code ih_cod from input xh_cod       ;
  686. ;            First compute eh then quantize on 2 bits               ;
  687. ;                                                                   ;
  688. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  689. ;;
  690. hsbcod    move     #dat_hsbcod,r2        ; set offset of data hsbcod
  691.     move     x:xh_cod,b        ; read xh_cod in b
  692.     move     x:(r2+sl),a        ; read prediction
  693.     sub     a,b  x:(r2+delt),y0    ; compute eh in a
  694. ;                    ; read deth in y0
  695. ;;
  696. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  697. ;                                                                   ;
  698. ;   Quanth : higher sub band 2 bits quantizer                       ;
  699. ;            eh in a                                                ;
  700. ;                                                                   ;
  701. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  702. ;;
  703. quanth    move     #4512,x0        ; level of quantization
  704.     mpy     y0,x0,a            ; compute wd,save eh
  705.     tst     b  a,x1            ; test for sign of eh
  706.     bmi     <cod_hi_mi        ; if neg bra cod_hi_mi
  707.     move     #3,x0            ; lower limit
  708.     move     #2,y0            ; upper limit
  709.     cmp     x1,b  x0,a        ; set a with lower limit
  710.     tpl     y0,a            ; if plus =>upper limit
  711.     bra     <end_q2            ; end of quant_h
  712. ;                    ; with ih in a
  713. cod_hi_mi inc24 b
  714.     abs     b            ; compute |eh|
  715.     move     #1,x0            ; lower limit
  716.     move     #0,y0            ; upper limit
  717.     cmp     x1,b  x0,a        ; set a with lower limit
  718.     tpl     y0,a            ; ih in a
  719. ;
  720. end_q2    move a,x:ih_cod            ; save code for higher sub_band
  721. ;;
  722. ;;    We must call subroutine pred_h
  723. ;;    ==============================
  724. ;;
  725.     move     #const_pr_h,r3        ; constant table for high band
  726.     jsr     pred_h            ; call subrouinte pred_h
  727.                     ; with ih_cod in a
  728.     move     a,x:(r2+sl)        ; save sh in hsbcod
  729. ;;
  730. ;;    Computation of is code from il_cod and ih_cod
  731. ;;    =============================================
  732. ;;
  733.     move     x:il_cod,a        ; read il in RAM
  734.     move     x:ih_cod,x0        ; read ih in RAM
  735.     move     #64,y0            ; for << 6
  736.     imac     y0,x0,a            ; to compute cod
  737.     move     a,x:is            ; save is code in RAM
  738.     rts                ; return of encoder
  739. ;;
  740. ;;    End of encoder procedure
  741. ;;    ========================
  742. ;;
  743. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  744. ;;
  745. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  746. ;;                                    ;;
  747. ;;    Subroutine decoder : compute yl_dec and yh_dec from ir         ;;
  748. ;;                         First compute ilr_dec and ihr_dec         ;;
  749. ;;                         Then execute lsbdec and hsbdec            ;;
  750. ;;                                                                     ;;
  751. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  752. ;;
  753. decoder    move     x:ir,a            ; read receive code ir
  754.     move     #63,x0            ; set mask for ilr_dec
  755.     move     #3,y0            ; set mask for ihr_dec
  756.     asr     a     a,b        ; shift a save a in b
  757.     asr4     a            ; to compute ihr_dec
  758.     asr     a            ; final shift of 6 shifts
  759.     and     y0,a            ; mask ihr_dec
  760.     and     x0,b            ; mask for ilr_dec
  761.     move     b,x:ilr_dec        ; save ilr_dec
  762.     move     a,x:ihr_dec        ; save ihr_dec
  763. ;;
  764. ;;    lsbdec
  765. ;;    ======
  766. ;;
  767. ;;    Select mode of operation of lower sub band decoder
  768. ;;    ==================================================
  769. ;;
  770.     move     #dat_lsbdec,r2        ; set data ram
  771.     move     #sel_mode,r0        ; load table sel_mode in r0
  772.     move     x:mode,a        ; read mode of decoder
  773.     and     y0,a      a0,x0        ; mask mode bits, x0 == 0 (#3 still in y0)
  774.     dec24     a    b,y1        ; compute modified mode, ilr_dec in y1
  775.     tmi     x0,a            ; select default mode ==1
  776. ;;
  777. ;;    read table sel_mode
  778. ;;    ===================
  779. ;;
  780.     rep     a1            ; repeat 0 1 or 2 times
  781.     asr     b  x:(r0)+,x1        ; shift and dummy read
  782.     move     b,n1            ; offset for table QQ6,QQ5 or QQ4
  783.     move     x:(r0),r1        ; selected table in r1
  784.     move     x:(r2+sl),b        ; read prediction in b
  785.     move     x:(r1)+n1,x0        ; dummy read to compute r1+n1
  786.     move     x:(r2),y0        ; read detl in ram
  787.     move     p:(r1),x0        ; read table of inverse quantizer
  788.     mac     y0,x0,b  y1,a        ; compute yl, a = ilr_dec
  789.     asl     b            ; limit yl to 16384
  790.     asr     b            ; end of limiting
  791.     move     #const_pr_l,r3        ; for lower predictor
  792.     move     b,x:yl_dec        ; save reconstructed signal
  793. ;;
  794. ;;    call pred_l
  795. ;;    ===========
  796. ;;
  797.     jsr     pred_l            ; lower predictor
  798.     move     a,x:(r2+sl)        ; save next prediction
  799. ;;
  800. ;;    hsbdec
  801. ;;    ======
  802. ;;
  803.     move     #dat_hsbdec,r2        ; select ram
  804.     move     #const_pr_h,r3        ; select higher constant
  805.     move     x:ihr_dec,a        ; read ih in a
  806. ;;
  807. ;;    call pred_h
  808. ;;    ===========
  809. ;;
  810.     jsr     pred_h            ; higher predictor
  811.     move    x:(r2+dlt0),b        ; reconstructed signal
  812.     move     x:(r2+sl),y1        ; last prediction
  813.     add     y1,b  a,x:(r2+sl)    ; compute yh, save new sl
  814.     asl     b            ; limit yh
  815.     asr     b            ; end of limiting
  816.     move    b,x:yh_dec        ; save yh_dec
  817. ;;
  818. ;;    end of decoder
  819. ;;    ==============
  820. ;;
  821.     rts
  822. ;;
  823. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  824. ;;                                                                   ;;
  825. ;;    Subroutine pred_l: compute invqal, logscl, scalel              ;;
  826. ;;                       then compute the adaptive predictor         ;;
  827. ;;    Input : il in a (lower subband code)                           ;;
  828. ;;            r3 must point on const_pr_l (constant for lower band)  ;;
  829. ;;            r2 must point on data ram for lower band               ;;
  830. ;;                                                                   ;;
  831. ;;    Subroutine pred_h: compute invqah, logsch, scaleh              ;;
  832. ;;                                                                   ;;
  833. ;;    Input : ih in a (higher subband code)                          ;;
  834. ;;            r3 must point on const_pr_h (constant for higher band) ;;
  835. ;;            r2 must point on data ram for higher band              ;;
  836. ;;                                                                   ;;
  837. ;;    NOTE: pred_l and pred_h are the same but the entry point of    ;;
  838. ;;          pred_h skip the >> 2 of input code                       ;;
  839. ;;                                                                   ;;
  840. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  841. ;;
  842. ;;    Invaqal/h: inverse quantizer on 4/2 bits
  843. ;;    ========================================
  844. ;;
  845. ;;    assume a = il/ih (level of quantizer)
  846. ;;
  847. pred_l    lsr     a
  848.     lsr     a            ; to compute ilr = il >>2
  849. pred_h    move     a1,n0            ; offset for table QQ4/QQ2
  850.     move     x:(r3)+,r0        ; to address table QQ4/QQ2
  851.     move     n0,n1            ; for table W4/W2
  852.     move     x:(r3)+,r1        ; to address table W4/W2
  853.     move     x:(r0)+n0,x1        ; table QQ4/QQ2 (dummy read)
  854.     move     x:(r2),x0        ; detl =first data in structure
  855.     move     p:(r0),x1        ; read inverse quantizer output
  856.     mpy     x1,x0,b x:(r1)+n1,x0    ; b=detl*IQ4/IQ2, dummy read->r1+n1
  857.     clr     b   b,x:(r2+dlt0)    ; b=0, save new dlt0 in ram
  858. ;;
  859. ;;    Begin Logscl/h
  860. ;;    ==============
  861. ;;
  862.     move     x:(r3)+,x0        ; x0 =32512
  863.     move     x:(r2+p_nbl),y1        ; read old p_nbl
  864.     mpy     y1,x0,a  x:(r3)+,y0    ; a= p_nbl*32512; y0=18432/22528)
  865.     move     p:(r1),y1        ; read table W4/W2
  866.     add     y1,a            ; compute p_nbl*32512 + wl in a
  867.     tmi     b,a            ; limit to 0 if < 0
  868.     cmp     y0,a            ; test if > 18432/22528
  869.     tpl     y0,a            ; limit to 18432/22528
  870. ;;
  871. ;;    Begin Scalel/h
  872. ;;    ==============
  873. ;;
  874.     asr     a  a,x:(r2+p_nbl)    ; save new p_nbl
  875.     asr     a  x:(r3)+,x0        ; to compute 9/11-wd2 = 1 +(8/10-wd2)
  876.     asr4     a            ; a = p_nbl >> 6
  877.     move     x:(r3)+,r0        ; to address the ILB table
  878.     move     #31,y1            ; for mask
  879.     and     y1,a  a,b        ; b = p_nbl >> 6
  880.     move     a1,n0            ; offset of table ILB
  881.     asr4     b
  882.     asr     b   x:(r0)+n0,y1    ; b = p_nbl>>11, dummy read,r0->
  883.     tfr     x0,b  b,y1        ; b= 9/11, y1 = wd2 (lsp set to 0)
  884.     sub     y1,b            ; b1 = 9/11 - wd2 (always >=0)
  885.     move     p:(r0),a        ; read table ILB*2 (ie 9-wd2)
  886.     rep     b1            ; b1 must be >=0
  887.     asr     a            ; a = a >> (9/11-wd2)
  888.     move     a,a            ; set lsp of a  to 0
  889.     asl     a
  890.     asl     a            ; a = a << 2
  891.     move     a,x:(r2)        ; save new detl
  892. ;;
  893. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  894. ;;                                                                       ;;
  895. ;;            Predictor : compute the following equations of the         ;;
  896. ;;            ========= : G722 predictor (see detailed recommendation    ;;
  897. ;;                      : and 'C' program)                             ;;
  898. ;;                      :          upzero(dlt,bl);                       ;;
  899. ;;                      :          plt[0]=parrec(dlt[0],szl);            ;;
  900. ;;                      :          rlt[0]=recons(sl,dlt[0]);             ;;
  901. ;;                      :          uppol2(al,plt);                       ;;
  902. ;;                      :          uppol1(al,plt);                       ;;
  903. ;;                      :          szl=filtez(dlt,bl);                   ;;
  904. ;;                      :          spl=filtep(rlt,al);                   ;;
  905. ;;                      :          sl=predic(spl,szl);                   ;;
  906. ;;                                                                       ;;
  907. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  908. ;;
  909. predictor clr b  x:(r2+dlt0),a    ; a = dlt0, b=0
  910.     move     #64,x0        ; x0 = 128/2
  911.     move     #-64,y0        ; y0 = -128/2
  912.     tst     a        ; set flag
  913.     tgt     x0,b        ; if >0 b =64
  914.     tlt     y0,b        ; if < 0 b=-64 (else b=0)
  915.     asl     b  b0,y1    ; b=2*b; y1 = 0
  916.     move     b,y0        ; sign suppressed in y
  917. ;;
  918. ;;    address computation
  919. ;;    ===================
  920. ;;
  921.     move     #dlt6,n2    ; for address computation
  922.     move     #-2,n0        ; for updating the delay line
  923.     lea     (r2)+n2,r0    ; r0 = address of dlt6
  924.     move     #bl6,n2        ; for adress computation
  925.     move     n0,n3        ; idem
  926.     lea     (r2)+n2,r3    ; r3 = address of bl6
  927. ;;
  928. ;;    upzero
  929. ;;    ======
  930. ;;
  931.     move     #32640,x1        ; fixed coefficient for bli
  932.     move     x:(r0)+,a x:(r3)+,x0    ; a= dlt6, x0 = bl6
  933.     add     y,a    (r0)+n0        ; a= dlt6+wd1, r0 = &dlt5
  934.     abs     a    (r3)+n3        ; set sign of a0, r3 =&bl5
  935.     mpy     x1,x0,b    a0,x0        ; x0 = wd2, b= 32640*bl6
  936.     add     x0,b x:(r0)+,a x:(r3)+,x0 ; b = new bl6, a= dlt5,x0= bl5
  937. ;;
  938. ;;    loop for the following bli
  939. ;;    ==========================
  940. ;;
  941.     do     #5,end_upzero
  942.     add     y,a    a,x:(r0)+n0    ;save dlti in dlti-1,r0 =&dlti+1
  943.     abs     a    b,x:(r3)+n3    ; save bli
  944.     mpy     x1,x0,b    a0,x0        ; x0 = wd2, b= 32640*bli-1
  945.     add     x0,b    x:(r0)+,a x:(r3)+,x0    ;b =new bli-1
  946. end_upzero
  947. ;;
  948. ;;    We must compute the new plt0 and the rlt0 and save 2*dlt0 in dlt1
  949. ;;    for the filtez computation
  950. ;;    Also we must save the new bl1 coefficients in ram
  951. ;;    =================================================
  952. ;;
  953.     tfr     a,x0  b,x:(r3)+        ; x0=a=dlt0, save bl1 in ram
  954.     asl     a  x:(r2+szl),b        ; a=2*dlt0, b= szl
  955.     add     x0,b x:(r2+plt1),x1    ; b= plt0, x1=plt1 (ie plt2)
  956.     tfr     b,y1  a,x:(r0)+        ; save 2*dlt0 in dlt1
  957.     eor     x1,b  x:(r2+sl),a    ; sg0^sg2=b, a= sl
  958.     add     x0,a  x:(r2+plt0),x0    ; a= rlt0, x0 = plt0 (ie plt1)
  959.     asl     a     x0,x:(r2+plt1)    ; a=2*rlt0, save new plt1
  960.     tfr     y1,a  a,x:(r2+rlt0)    ; a= plt0, save 2*rlt0 in ram
  961.     eor     x0,a  y1,x:(r2+plt0)    ; sg0^sg1=a, save new plt0
  962.  
  963. ;;    uppol2 and uppol1
  964. ;;    =================
  965. ;;
  966. ;;    uppol2
  967. ;;    ======
  968. ;;
  969.     move     a1,x1            ; x1 = sg0 ^ sg1
  970.     move     b1,y1            ; y1 = sg0 ^ sg2
  971.     move     x:(r2+al1),a        ; a= al1
  972.     move     #-192,b            ; b=-192
  973.     neg     b    b,y0        ; b =192, y0 = -192
  974.     asl     a            ; to compute wd1
  975.     asl     a            ; for limiting and fixe a0 to 0
  976.     neg     a    a,x0        ; a= -wd1 , x0 = wd1 (4*al1)
  977.     tst     x1            ; test if sg0 ^ sg1 == 1 or 0
  978.     tlt     x0,a            ; if 1 a= wd1 ==>wd2
  979.     tlt     y0,b            ; if 1 b = -192 (wd1 of uppol1)
  980.     asr4     a            ; wd2 >>4
  981.     asr4     a            ; wd2 >>4
  982.     asl     a    b,y0        ; wd2 <<1
  983.                     ; y0 = wd1_uppol1
  984.     move     #128,b            ; for wd3
  985.     move     #-128,x0        ; for -wd3
  986.     tst     y1            ; test sg0 ^ sg2
  987.     tlt     x0,b            ; set b to wd3
  988.     add     a,b    x:(r2+al2),x0    ; b= wd4, read al2 in x0
  989.     move     #32512,y1        ; set 32512 in y1
  990.     move     b,b            ; limit wd4
  991.     mac     y1,x0,b            ; b= apl2
  992.     move     #-12288,a        ; set lower limit in a
  993.     move     b,b            ; limit apl2
  994.     neg     a    a,x0        ; a= 12288, x0=-12288
  995.     cmp     a,b            ; compare apl2 with +12288
  996.     tpl     a,b            ; set b to 12288 if gt
  997.     cmp     x0,b            ; compare apl2 with -12288
  998.     tmi     x0,b            ; set b to -12288 if lt
  999.     tfr     y0,a b,x:(r2+al2)    ; y0 = wd1, save new al2
  1000. ;;
  1001. ;;    uppol1
  1002. ;;    ======
  1003. ;;
  1004.     move     #15360,x0        ; to compute wd3
  1005.     sub     x0,b    x:(r2+al1),x0    ; b = -wd3, x0 = al1
  1006.     neg     b    b,y0        ; b = wd3 , y0 = -wd3
  1007.     move     #32640,x1        ; factor of al1
  1008.     mac     x0,x1,a            ; a= apl1
  1009.     move     a,a            ; limit apl1
  1010.     cmp     b,a            ; test if a > wd3
  1011.     tpl     b,a            ; set a to wd3 if gt
  1012.     cmp     y0,a            ; test if a < wd3
  1013.     tmi     y0,a            ; set to -wd3 if lt
  1014. ;;
  1015. ;;    filtez
  1016. ;;    ======
  1017. ;;
  1018.     move     #dlt6,n2        ; for computation updating
  1019.     move     #-1,n0            ; n0 = -1
  1020.     lea     (r2)+n2,r0        ; r0 = address of dlt6
  1021.     move     #bl6,n2            ;
  1022.     move     n0,n3            ; n3 =-1
  1023.     lea     (r2)+n2,r3        ; r3 = address of bl6
  1024. ;;
  1025.     move     a,x:(r2+al1)        ; save new al1
  1026. ;;
  1027.     move     x:(r0)+n0,y1 x:(r3)+n3,x1        ; y1 =dlt6, x1 = bl6
  1028.     mpy     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt5, x1 = bl5
  1029.     move     a,a                    ; limit partial product
  1030.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt4, x1 = bl4
  1031.     move     a,a                    ; limit partial product
  1032.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt3, x1 = bl3
  1033.     move     a,a                    ; limit partial product
  1034.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt2, x1 = bl2
  1035.     move     a,a                    ; limit partial product
  1036.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt1, x1 = bl1
  1037.     move     a,a                    ; limit partial product
  1038.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt0, x1 = al2
  1039. ;;                            ; a = szl then limit in x0
  1040. ;;
  1041. ;;    filtep
  1042. ;;    ======
  1043. ;;
  1044.  
  1045.     tfr     a,x0    x:(r0)+n0,y1            ; y1 =rlt1, x0 =szl
  1046.     mpy     x1,y1,a x:(r0)+,y1 x:(r3)+n3,x1        ; y1 =rlt0, x1 = al1
  1047.     move     a,a                    ; limit al2 * rlt2
  1048.     mac     x1,y1,a x0,x:(r2+szl)            ; save szl
  1049.     add     x0,a    y1,x:(r0)+            ; rlt0 in rlt1
  1050.                                         ; prediction in accu a
  1051. ;;
  1052. ;;    return of subroutine pred_l or pred_h
  1053. ;;
  1054. ;;    ===============================================================
  1055. ;;    WARNING: the prediction sl or sh is in accu A and must be saved
  1056. ;;             in the calling procedure
  1057. ;;    ===============================================================
  1058. ;;
  1059.     rts
  1060. ;;
  1061. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1062. ;                                    ;
  1063. ;  reset_cod: subroutine to reset the encoder (lower and higher)    ;
  1064. ;             state variables                                       ;
  1065. ;             We must call this subroutine in order to pass the     ;
  1066. ;             digital test sequences of the CCITT G722              ;
  1067. ;                                    ;
  1068. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1069. ;
  1070. reset_cod move     #dat_lsbcod,r0        ; pointer to data of l_coder
  1071.     move     #32,x0            ; set detl for reset
  1072.     move     x0,x:(r0)+        ; save in memory
  1073.     clr     a            ; set a to 0
  1074.     rep     #22            ; set 22 state variables to 0
  1075.     move     a,x:(r0)+        ; end for coder_low
  1076. ;
  1077.     move     #dat_hsbcod,r0        ; pointer to data of h_coder
  1078.     move     #8,x0            ; set deth for reset
  1079.     move     x0,x:(r0)+        ; save in memory
  1080.     rep     #22            ; set 22 state variables to 0
  1081.     move     a,x:(r0)+        ; end for coder_high
  1082. ;
  1083.     rts                ; return of subroutine
  1084. ;
  1085. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1086. ;                                    ;
  1087. ;  reset_dec: subroutine to reset the decoder (lower and higher)    ;
  1088. ;             states variables                                      ;
  1089. ;             We must call this subroutine in order to pass the     ;
  1090. ;             digital test sequences of CCITT G722                  ;
  1091. ;                                    ;
  1092. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1093. ;
  1094. reset_dec move     #dat_lsbdec,r0        ; pointer to data of l_decoder
  1095.     move     #32,x0            ; set detl for reset
  1096.     move     x0,x:(r0)+        ; save in memory
  1097.     clr     a            ; set a to 0
  1098.     rep     #22            ; set 22 state variables to 0
  1099.     move    a,x:(r0)+        ; end for decoder_low
  1100. ;
  1101.     move     #dat_hsbdec,r0        ; pointer to data of h_decoder
  1102.     move     #8,x0            ; set deth for reset
  1103.     move     x0,x:(r0)+        ; save in memory
  1104.     rep     #22            ; set 22 state variables to 0
  1105.     move     a,x:(r0)+        ; end for decoder_low
  1106. ;
  1107.     rts                ; return of subroutine
  1108. ;
  1109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1110. ;;
  1111. ;;    Subroutine to initialise qmf TX filter
  1112. ;;    ======================================
  1113. ;;    Set to 0 all the delay line and initialize the pointer
  1114. ;;
  1115. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1116. ;;
  1117. init_q_tx move #dat_q_tx,r0        ; adress of delay line
  1118.     clr     a            ; a to 0
  1119.     move     r0,x:ptr_q_tx        ; save pointer value
  1120.     rep     #24            ; for 24 elements
  1121.     move     a,x:(r0)+        ; set all the line to 0
  1122.     rts                ; end of subprogram
  1123. ;;
  1124. ;;    end of init_q_tx
  1125. ;;    ================
  1126. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1127. ;;
  1128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1129. ;;
  1130. ;;    Subroutine to initialise qmf RX filter
  1131. ;;    ======================================
  1132. ;;    Set to 0 all the delay line and initialize the pointer
  1133. ;;
  1134. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1135. ;;
  1136. init_q_rx move     #dat_q_rx,r0        ; address of delay line
  1137.     clr     a            ; a to 0
  1138.     move     r0,x:ptr_q_rx        ; save pointer value
  1139.     rep     #24            ; for 24 elements
  1140.     move    a,x:(r0)+        ; set all the line to 0
  1141.     rts                ; end of subprogram
  1142. ;;
  1143. ;;    end of init_q_rx
  1144. ;;    ================
  1145. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1146. ;;
  1147. ;;    Subroutine to initialise constant in data ram
  1148. ;;    =============================================
  1149. ;;
  1150. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1151. ;;
  1152. init_const move #pr_sel_mode,r0        ; start of sel_mode
  1153.     move     #sel_mode,r3        ; in ram
  1154.     rep     #3            ; for 3 values
  1155.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1156. ;;
  1157.     move     #pr_const_pr_l,r0    ; start of const_pr_l
  1158.     move     #const_pr_l,r3        ; in ram
  1159.     rep     #6            ; for 3 values
  1160.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1161. ;;
  1162.     move     #pr_const_pr_h,r0    ; start of const_pr_h
  1163.     move     #const_pr_h,r3        ; in ram
  1164.     rep     #6            ; for 3 values
  1165.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1166. ;;
  1167.     move     #pr_level__1,r0        ; start of level__1
  1168.     move     #level__1,r3        ; in ram
  1169.     rep     #31            ; for 3 values
  1170.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1171. ;;
  1172.     move     #pr_q_coef,r0        ; start of q_ceof
  1173.     move     #q_coef,r3        ; in ram
  1174.     rep     #24            ; for 3 values
  1175.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1176. ;;
  1177.  
  1178.     rts                ; end of subprogram
  1179. ;;
  1180. ;;    end of init_const
  1181. ;;    =================
  1182. ;;
  1183. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1184. ;;
  1185. ;;    Subroutine qmf_tx:     transmit QMF filter operating at 8 kHz
  1186. ;;                input two samples at 16 kHz and output 
  1187. ;;                a low_band value and a high_band value
  1188. ;;
  1189. ;;    The input values are first_codec_rx and second_codec_rx
  1190. ;;    The ouput values are xl_cod and xh_cod
  1191. ;;
  1192. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1193. ;;
  1194. qmf_tx    move     x:ptr_q_tx,r0        ; recall pointer
  1195.     move     m0,x:ptr_q_tx        ; save m0 value
  1196.     move     #23,m0            ; modulo 24 for the delay line
  1197.     move     #q_coef,r3        ; for QMF TX and RX coefficients
  1198. ;;
  1199. ;;    Read the two values from ADC converter and scale them
  1200. ;;    ADC is supposed to be 16 bits (left justfified,14 bits precison)
  1201. ;;    ================================================================
  1202. ;;
  1203.     move     x:first_codec_rx,b    ; the first codec reception
  1204.     move     x:second_codec_rx,a    ; the second codec reception
  1205.     move     b,x:(r0)+        ; save first in modulo delay line
  1206.     move     a,x:(r0)+        ; save second in modulo delay line
  1207.                     ; r0 points on H[23]
  1208. ;;
  1209. ;;    Begin mac operation: ACCUMA in a and ACCUMB in b
  1210. ;;    ================================================
  1211. ;;
  1212.     clr     a    x:(r0)+,y0    ; read xin[23]
  1213.     clr     b    x:(r3)+,x0    ; read h[23]
  1214.  
  1215.     do     #12,end_q_tx            ; for 12 values
  1216.     mac     x0,y0,b  x:(r0)+,y1  x:(r3)+,x1 ; mac and read next values
  1217.     mac     x1,y1,a  x:(r0)+,y0  x:(r3)+,x0 ; mac and read next values
  1218. end_q_tx                    ; end of do loop
  1219. ;;
  1220. ;;    Now save updated pointer and end the computation of xl_cod an xh
  1221. ;;    ===============================================================
  1222. ;;
  1223.     tfr     b,x            ; save 32 bit result in x
  1224.     add     a,b    (r0)-        ; compute xl_cod
  1225.     sub     x,a            ; compute xh_cod
  1226. ;;
  1227. ;;    Limiting the output values
  1228. ;;    ==========================
  1229. ;;
  1230.     asl     a            ; times 2
  1231.     asr     a            ; linited to -16384 and +16383
  1232.     asl     b            ; times 2
  1233.     asr     b            ; linited to -16384 and +16383
  1234.     move     b,x:xl_cod        ; for input of lsbcod
  1235.     move     a,x:xh_cod        ; for input of hsbdec
  1236.     move     x:ptr_q_tx,m0        ; recall m0 value
  1237.     move     r0,x:ptr_q_tx        ; save modulo pointer
  1238. ;;
  1239. ;;    end of qmf_tx subroutine
  1240. ;;    ========================
  1241. ;;
  1242.     rts
  1243. ;;
  1244. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1245. ;;
  1246. ;;    Subroutine for RX QMF filter
  1247. ;;    Compute two values from yl_dec and yh_dec (output of lsbdec and
  1248. ;;    hsbdec); the outputs are first_codec_tx and second_codec_tx.
  1249. ;;
  1250. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1251. ;;
  1252. qmf_rx    move     x:ptr_q_rx,r0        ; recall saved pointer
  1253.     move     m0,x:ptr_q_rx        ; save old value of m0
  1254.     move     #23,m0            ; modulo 24 pointer
  1255.     move     #q_coef,r3        ; address of coefficients
  1256. ;;
  1257. ;;    Compute XS and XD (RECB and RECA) G722 procedure
  1258. ;;    ================================================
  1259. ;;
  1260.     move     x:yl_dec,a        ; recall yl = rl G722
  1261.     move     x:yh_dec,b        ; recall yh = rh G722
  1262.     add     a,b    b,y0        ; xs in b, x0 = rh
  1263.     sub     y0,a    b,x:(r0)+    ; xd in a, save xs
  1264.     move     a,x:(r0)+        ; save xd in delay line
  1265.                     ; now r0 points on xs11
  1266. ;;
  1267. ;;    Begin mac computation
  1268. ;;    =====================
  1269. ;;
  1270.     clr     a    x:(r0)+,y0    ; read xs11
  1271.     clr     b    x:(r3)+,x0    ; read H[23]
  1272. ;;
  1273.     do     #12,end_q_rx            ; for 12 values
  1274.     mac     x0,y0,b  x:(r0)+,y1  x:(r3)+,x1 ; mac and read next values
  1275.     mac     x1,y1,a  x:(r0)+,y0  x:(r3)+,x0 ; mac and read next values
  1276. end_q_rx                    ; end of do loop
  1277. ;;
  1278. ;;    Scaling for output
  1279. ;;    ==================
  1280. ;;
  1281.     asl     a    (r0)-        ; for times 2
  1282.     asl     b            ; for times 2
  1283.     asl     a            ; for coefficients scaling
  1284.     asl     a            ; 
  1285.     asl     b            ; for coefficients scaling
  1286.     asl     b            ; 
  1287.     move     b,x:second_codec_tx    ; the second DAC output
  1288.     move     a,x:first_codec_tx    ; the first DAC output
  1289.     move     x:ptr_q_rx,m0        ; recall m0 value
  1290.     move     r0,x:ptr_q_rx        ; save modulo pointer
  1291. ;;
  1292. ;;    End of subroutine qmf_rx
  1293. ;;    ========================
  1294. ;;
  1295.     rts
  1296. ;;
  1297. ;;
  1298. ;;    SSIO interrupt with exception section
  1299. ;;    =====================================
  1300. ;;
  1301. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1302. ;;
  1303. ;;        transmit underrun error 
  1304. ;;
  1305. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1306. ;;
  1307. roe_rx_0     nop                ; follows the normal interrupt
  1308.          move     x0,x:temp_x0        ; save register x0
  1309. ;;
  1310.         rep    #2
  1311.          move     x:a_sr_0,x0        ; clear execption
  1312. ;;
  1313.         move     x:a_txrx_0,x0        ; read received word
  1314. ;;
  1315.         move     x:temp_x0,x0        ; restore x0
  1316. ;;
  1317.         rti
  1318. ;;
  1319. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1320. ;;
  1321. ;;        transmit underrun error 
  1322. ;;
  1323. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1324. ;;
  1325. tue_tx_0     nop                ; follows the normal interrupt
  1326.          move     x0,x:temp_x0        ; save register x0
  1327. ;;
  1328.         rep    #2
  1329.          move     x:a_sr_0,x0        ; clear execption
  1330. ;;
  1331.         move     x0,x:a_txrx_0        ; write transmit word
  1332. ;;
  1333.         move     x:temp_x0,x0        ; restore x0
  1334. ;;
  1335.         rti
  1336. ;;
  1337. ;;
  1338. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1339. ;
  1340. ;    Table for coding il in lower sub band
  1341. ;    =====================================
  1342. ;
  1343. cod_6_mi    dc     %0000000000111111
  1344.         dc     %0000000000111111
  1345.         dc     %0000000000111110
  1346.         dc     %0000000000011111
  1347.         dc     %0000000000011110
  1348.         dc     %0000000000011101
  1349.         dc     %0000000000011100
  1350.         dc     %0000000000011011
  1351.         dc     %0000000000011010
  1352.         dc     %0000000000011001
  1353.         dc     %0000000000011000
  1354.         dc     %0000000000010111
  1355.         dc     %0000000000010110
  1356.         dc     %0000000000010101
  1357.         dc     %0000000000010100
  1358.         dc     %0000000000010011
  1359.         dc     %0000000000010010
  1360.         dc     %0000000000010001
  1361.         dc     %0000000000010000
  1362.         dc     %0000000000001111
  1363.         dc     %0000000000001110
  1364.         dc     %0000000000001101
  1365.         dc     %0000000000001100
  1366.         dc     %0000000000001011
  1367.         dc     %0000000000001010
  1368.         dc     %0000000000001001
  1369.         dc     %0000000000001000
  1370.         dc     %0000000000000111
  1371.         dc     %0000000000000110
  1372.         dc     %0000000000000101
  1373.         dc     %0000000000000100
  1374.         dc     %0000000000000100
  1375.         dc     %0000000000000100
  1376. ;    
  1377. ;
  1378. cod_6_pl    dc     %0000000000111101
  1379.         dc     %0000000000111101
  1380.         dc     %0000000000111100
  1381.         dc     %0000000000111011
  1382.         dc     %0000000000111010
  1383.         dc     %0000000000111001
  1384.         dc     %0000000000111000
  1385.         dc     %0000000000110111
  1386.         dc     %0000000000110110
  1387.         dc     %0000000000110101
  1388.         dc     %0000000000110100
  1389.         dc     %0000000000110011
  1390.         dc     %0000000000110010
  1391.         dc     %0000000000110001
  1392.         dc     %0000000000110000
  1393.         dc     %0000000000101111
  1394.         dc     %0000000000101110
  1395.         dc     %0000000000101101
  1396.         dc     %0000000000101100
  1397.         dc     %0000000000101011
  1398.         dc     %0000000000101010
  1399.         dc     %0000000000101001
  1400.         dc     %0000000000101000
  1401.         dc     %0000000000100111
  1402.         dc     %0000000000100110
  1403.         dc     %0000000000100101
  1404.         dc     %0000000000100100
  1405.         dc     %0000000000100011
  1406.         dc     %0000000000100010
  1407.         dc     %0000000000100001
  1408.         dc     %0000000000100000
  1409.         dc     %0000000000100000
  1410.         dc     %0000000000100000
  1411. ;    
  1412. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1413. ;;
  1414. ;;    Table ILB for scalel
  1415. ;;    ====================
  1416. ;;    Note: table ILB is scaled by 2 to avoid check of 8-wd2 <0
  1417. ;;    ====  in the shift operation
  1418. ;;
  1419. ;;
  1420. ILB        dc     2048*2
  1421.         dc     2093*2
  1422.         dc     2139*2
  1423.         dc     2186*2
  1424.         dc     2233*2
  1425.         dc     2282*2
  1426.         dc     2332*2
  1427.         dc     2383*2
  1428.         dc     2435*2
  1429.         dc     2489*2
  1430.         dc     2543*2
  1431.         dc     2599*2
  1432.         dc     2656*2
  1433.         dc     2714*2
  1434.         dc     2774*2
  1435.         dc     2834*2
  1436.         dc     2896*2
  1437.         dc     2960*2
  1438.         dc     3025*2
  1439.         dc     3091*2
  1440.         dc     3158*2
  1441.         dc     3228*2
  1442.         dc     3298*2
  1443.         dc     3371*2
  1444.         dc     3444*2
  1445.         dc     3520*2
  1446.         dc     3597*2
  1447.         dc     3676*2
  1448.         dc     3756*2
  1449.         dc     3838*2
  1450.         dc     3922*2
  1451.         dc     4008*2
  1452. ;;    
  1453. ;;    end of table ILB
  1454. ;;    ================
  1455. ;
  1456. ;    quantiser thresholds (Q6) for lower sub_band encoder
  1457. ;    ====================================================
  1458. ;
  1459. INICOD        dc       0*8        ; Q6( 0)
  1460.         dc      35*8        ; Q6( 1)
  1461.         dc      72*8        ; Q6( 2)
  1462.         dc     110*8        ; Q6( 3)
  1463.         dc     150*8        ; Q6( 4)
  1464.         dc     190*8        ; Q6( 5)
  1465.         dc     233*8        ; Q6( 6)
  1466.         dc     276*8        ; Q6( 7)
  1467.         dc     323*8        ; Q6( 8)
  1468.         dc     370*8        ; Q6( 9)
  1469.         dc     422*8        ; Q6(10)
  1470.         dc     473*8        ; Q6(11)
  1471.         dc     530*8        ; Q6(19)
  1472.         dc     587*8        ; Q6(13)
  1473.         dc     650*8        ; Q6(14)
  1474.         dc     714*8        ; Q6(15)
  1475.         dc     786*8        ; Q6(16)
  1476.         dc     858*8        ; Q6(17)
  1477.         dc     940*8        ; Q6(18)
  1478.         dc    1023*8        ; Q6(19)
  1479.         dc    1121*8        ; Q6(20)
  1480.         dc    1219*8        ; Q6(21)
  1481.         dc    1339*8        ; Q6(22)
  1482.         dc    1458*8        ; Q6(23)
  1483.         dc    1612*8        ; Q6(24)
  1484.         dc    1765*8        ; Q6(25)
  1485.         dc    1980*8        ; Q6(26)
  1486.         dc    2195*8        ; Q6(27)
  1487.         dc    2557*8        ; Q6(28)
  1488.         dc    2919*8        ; Q6(29)
  1489.         dc    2919*8        ; Q6(30)
  1490.         dc    2919*8        ; Q6(31)
  1491. ;
  1492. ;
  1493. ;    Inverse quantizer (Q6)
  1494. ;    ======================
  1495. ;
  1496. QQ6        dc      -17*8        ; code 000000
  1497.         dc      -17*8        ; code 000001
  1498.         dc      -17*8        ; code 000010
  1499.         dc      -17*8        ; code 000011
  1500.         dc     -3101*8        ; code 000100
  1501.         dc    -2738*8        ; code 000101
  1502.         dc    -2376*8        ; code 000110
  1503.         dc    -2088*8        ; code 000111
  1504.         dc    -1873*8        ; code 001000
  1505.         dc    -1689*8        ; code 001001
  1506.         dc    -1535*8        ; code 001010
  1507.         dc    -1399*8        ; code 001011
  1508.         dc    -1279*8        ; code 001100
  1509.         dc    -1170*8        ; code 001101
  1510.         dc    -1072*8        ; code 001110
  1511.         dc     -982*8        ; code 001111
  1512.         dc     -899*8        ; code 010000
  1513.         dc     -822*8        ; code 010001
  1514.         dc     -750*8        ; code 010010
  1515.         dc     -682*8        ; code 010011
  1516.         dc     -618*8        ; code 010100
  1517.         dc     -558*8        ; code 010101
  1518.         dc     -501*8        ; code 010110
  1519.         dc     -447*8        ; code 010111
  1520.         dc     -396*8        ; code 011000
  1521.         dc     -347*8        ; code 011001
  1522.         dc     -300*8        ; code 011010
  1523.         dc     -254*8        ; code 011011
  1524.         dc     -211*8        ; code 011100
  1525.         dc     -170*8        ; code 011101
  1526.         dc     -130*8        ; code 011110
  1527.         dc      -91*8        ; code 011111
  1528.         dc     3101*8        ; code 100000
  1529.         dc     2738*8        ; code 100001
  1530.         dc     2376*8        ; code 100010
  1531.         dc     2088*8        ; code 100011
  1532.         dc     1873*8        ; code 100100
  1533.         dc     1689*8        ; code 100101
  1534.         dc     1535*8        ; code 100110
  1535.         dc     1399*8        ; code 100111
  1536.         dc     1279*8        ; code 101000
  1537.         dc     1170*8        ; code 101001
  1538.         dc     1072*8        ; code 101010
  1539.         dc      982*8        ; code 101011
  1540.         dc      899*8        ; code 101100
  1541.         dc      822*8        ; code 101101
  1542.         dc      750*8        ; code 101110
  1543.         dc      682*8        ; code 101111
  1544.         dc      618*8        ; code 110000
  1545.         dc      558*8        ; code 110001
  1546.         dc      501*8        ; code 110010
  1547.         dc      447*8        ; code 110011
  1548.         dc      396*8        ; code 110100
  1549.         dc      347*8        ; code 110101
  1550.         dc      300*8        ; code 110110
  1551.         dc      254*8        ; code 110111
  1552.         dc      211*8        ; code 111000
  1553.         dc      170*8        ; code 111001
  1554.         dc      130*8        ; code 111010
  1555.         dc       91*8        ; code 111011
  1556.         dc       54*8        ; code 111100
  1557.         dc       17*8        ; code 111101
  1558.         dc      -54*8        ; code 111110
  1559.         dc      -17*8        ; code 111111
  1560. ;;    
  1561. ;
  1562. ;    Inverse quantizer (Q5)
  1563. ;    ======================
  1564. ;
  1565. QQ5        dc      -35*8        ; code 00000
  1566.         dc      -35*8        ; code 00001
  1567.         dc    -2919*8        ; code 00010
  1568.         dc    -2195*8        ; code 00011
  1569.         dc    -1765*8        ; code 00100
  1570.         dc    -1458*8        ; code 00101
  1571.         dc    -1219*8        ; code 00110
  1572.         dc    -1023*8        ; code 00111
  1573.         dc     -858*8        ; code 01000
  1574.         dc     -714*8        ; code 01001
  1575.         dc     -587*8        ; code 01010
  1576.         dc     -473*8        ; code 01011
  1577.         dc     -370*8        ; code 01100
  1578.         dc     -276*8        ; code 01101
  1579.         dc     -190*8        ; code 01110
  1580.         dc     -110*8        ; code 01111
  1581.         dc     2919*8        ; code 10000
  1582.         dc     2195*8        ; code 10001
  1583.         dc     1765*8        ; code 10010
  1584.         dc     1458*8        ; code 10011
  1585.         dc     1219*8        ; code 10100
  1586.         dc     1023*8        ; code 10101
  1587.         dc      858*8        ; code 10110
  1588.         dc      714*8        ; code 10111
  1589.         dc      587*8        ; code 11000
  1590.         dc      473*8        ; code 11001
  1591.         dc      370*8        ; code 11010
  1592.         dc      276*8        ; code 11011
  1593.         dc      190*8        ; code 11100
  1594.         dc      110*8        ; code 11101
  1595.         dc       35*8        ; code 11110
  1596.         dc      -35*8        ; code 11111
  1597. ;;    
  1598. ;    
  1599. ;    Inverse quantizer (Q4)
  1600. ;    ======================
  1601. ;
  1602. QQ4        dc        0*8        ; code 0000
  1603.         dc    -2557*8        ; code 0001
  1604.         dc    -1612*8        ; code 0010
  1605.         dc    -1121*8        ; code 0011
  1606.         dc     -786*8        ; code 0100
  1607.         dc     -530*8        ; code 0101
  1608.         dc     -323*8        ; code 0110
  1609.         dc     -150*8        ; code 0111
  1610.         dc     2557*8        ; code 1000
  1611.         dc     1612*8        ; code 1001
  1612.         dc     1121*8        ; code 1010
  1613.         dc      786*8        ; code 1011
  1614.         dc      530*8        ; code 1100
  1615.         dc      323*8        ; code 1101
  1616.         dc      150*8        ; code 1110
  1617.         dc        0*8        ; code 1111
  1618. ;;    
  1619. ;    Inverse quantizer (Q2)
  1620. ;    ======================
  1621. ;
  1622. QQ2        dc     -926*8        ; code   00
  1623.         dc     -202*8        ; code   01
  1624.         dc      926*8        ; code   10
  1625.         dc      202*8        ; code   11
  1626. ;    
  1627. ;    Multiplication factor
  1628. ;    =====================
  1629. ;
  1630. W4        dc      -60        ; code 0000
  1631.         dc     3042        ; code 0001
  1632.         dc     1198        ; code 0010
  1633.         dc      538        ; code 0011
  1634.         dc      334        ; code 0100
  1635.         dc      172        ; code 0101
  1636.         dc       58        ; code 0110
  1637.         dc      -30        ; code 0111
  1638.         dc     3042        ; code 1000
  1639.         dc     1198        ; code 1001
  1640.         dc      538        ; code 1010
  1641.         dc      334        ; code 1011
  1642.         dc      172        ; code 1100
  1643.         dc       58        ; code 1101
  1644.         dc      -30        ; code 1110
  1645.         dc      -60        ; code 1111
  1646. ;;    
  1647. ;;
  1648. W2         dc      798        ; code   00
  1649.             dc     -214        ; code   01
  1650.             dc      798        ; code   10
  1651.             dc     -214        ; code   11
  1652. ;;    
  1653. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1654. ;; 
  1655. ;;     Tables of constants that must be loaded in data RAM at reset
  1656. ;;    ============================================================
  1657. ;;
  1658. ;;    Note: they have the same name but with a pr_ prefix (prom)
  1659. ;;    ==========================================================
  1660. ;;
  1661. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1662. ;;
  1663. ;;    Table for selection of decoder (mode)
  1664. ;;    =====================================
  1665. ;;
  1666. pr_sel_mode    dc     QQ6        ; for mode 1 = 64 kbit/s
  1667.         dc     QQ5        ; for mode 2 = 56 kbit/s
  1668.         dc     QQ4        ; for mode 3 = 48 kbit/s
  1669. ;;
  1670. ;;    constant area for lower sub band predictor
  1671. ;;    ==========================================
  1672. ;;
  1673. pr_const_pr_l     dc     QQ4        ; inverse 4 bits quantizer
  1674.         dc     W4        ; log adaptation (4 bits)
  1675.         dc     32512        ; multiplicand factor
  1676.         dc     18432        ; upper limit of p_nbl (low sub band)
  1677.         dc     9        ; to compute shift right
  1678.         dc     ILB        ; table of 32 values
  1679. ;;
  1680. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1681. ;;
  1682. ;;    constant area for higher sub band predictor
  1683. ;;    ===========================================
  1684. ;;
  1685. pr_const_pr_h     dc     QQ2        ; inverse 2 bits quantizer
  1686.         dc     W2        ; log adaptation (2 bits)
  1687.         dc     32512        ; multiplicand factor
  1688.         dc     22528        ; upper limit of p_nbl (high sub band)
  1689.         dc     11        ; to compute shift right
  1690.         dc     ILB        ; table of 32 values
  1691. ;;
  1692. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1693. ;;
  1694. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1695. ;
  1696. ;    quantiser thresholds (Q6) for lower sub_band encoder
  1697. ;    ====================================================
  1698. ;
  1699. pr_level__1    dc      0*8        ; Q6(-1)
  1700. pr_level_0    dc      0*8        ; Q6( 0)
  1701. pr_level_1    dc      35*8        ; Q6( 1)
  1702. pr_level_2    dc      72*8        ; Q6( 2)
  1703. pr_level_3    dc     110*8        ; Q6( 3)
  1704. pr_level_4    dc     150*8        ; Q6( 4)
  1705. pr_level_5    dc     190*8        ; Q6( 5)
  1706. pr_level_6    dc     233*8        ; Q6( 6)
  1707. pr_level_7    dc     276*8        ; Q6( 7)
  1708. pr_level_8    dc     323*8        ; Q6( 8)
  1709. pr_level_9    dc     370*8        ; Q6( 9)
  1710. pr_level_10    dc     422*8        ; Q6(10)
  1711. pr_level_11    dc     473*8        ; Q6(11)
  1712. pr_level_12    dc     530*8        ; Q6(19)
  1713. pr_level_13    dc     587*8        ; Q6(13)
  1714. pr_level_14    dc     650*8        ; Q6(14)
  1715. pr_level_15    dc     714*8        ; Q6(15)
  1716. pr_level_16    dc     786*8        ; Q6(16)
  1717. pr_level_17    dc     858*8        ; Q6(17)
  1718. pr_level_18    dc     940*8        ; Q6(18)
  1719. pr_level_19    dc    1023*8        ; Q6(19)
  1720. pr_level_20    dc    1121*8        ; Q6(20)
  1721. pr_level_21    dc    1219*8        ; Q6(21)
  1722. pr_level_22    dc    1339*8        ; Q6(22)
  1723. pr_level_23    dc    1458*8        ; Q6(23)
  1724. pr_level_24    dc    1612*8        ; Q6(24)
  1725. pr_level_25    dc    1765*8        ; Q6(25)
  1726. pr_level_26    dc    1980*8        ; Q6(26)
  1727. pr_level_27    dc    2195*8        ; Q6(27)
  1728. pr_level_28    dc    2557*8        ; Q6(28)
  1729. pr_level_29    dc    2919*8        ; Q6(29)
  1730. ;;
  1731. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1732. ;;
  1733. ;;    Coefficients for QMF TX and RX filters
  1734. ;;    ======================================
  1735. ;;    Note: they must be seen as H[23],H[22] and so on
  1736. ;;    ------------------------------------------------
  1737. ;;
  1738. pr_q_coef    dc     3*2,-11*2,-11*2,53*2,12*2,-156*2
  1739.         dc     32*2,362*2,-210*2,-805*2,951*2,3876*2
  1740.         dc     3876*2,951*2,-805*2,-210*2,362*2,32*2
  1741.         dc     -156*2,12*2,53*2,-11*2,-11*2,3*2
  1742. ;;
  1743. ;;
  1744. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1745.     end